<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>一个购物车案例</title>
  <script src="../vue.js"></script>
</head>
<body>
  <div id="app">
    <h1>产品列表</h1>
    <hr>
    <Products @add-to-cart="handleAddToCart"></Products>
    <h1>购物车产品</h1>
    <hr>
    <Cart :cart-items="cartItems"></Cart>
    <custom-input v-model="inputValue"></custom-input>
    <div>
      {{inputValue}}
    </div>
  </div>
  <script type="module">
    import './Products.js'
    import './Cart.js'
    import './CustomInput.js'

    new Vue({
      el: '#app',
      data: {
        cartItems: [],
        inputValue: ''
      },
      methods: {
        handleAddToCart(cartItems) {
          this.cartItems = cartItems
        }
      }
    })
  </script>
</body>
</html>